<template>
		<view>
			<view class="top-wrap">
        <image src="https://xbsg.oss-cn-shanghai.aliyuncs.com/files/2022/09/29/16644396563692516.png" style="width: 100%;" mode="widthFix"></image>
			</view>

			<view class="xb-card glgj" v-if="permissList">
				<view class="glgj-t">
					管理信息
				</view>
				<view class="glgj-c">
					<view v-for="(item,index) in permissList" :key="index" v-if="item.look&&item.children" class="glgj-col"
						hover-class="button-hover" @click="goMenusInfo(item)">
						<image :src="item.iconPath"></image>
						<view>
							{{ item.menuName }}
						</view>
					</view>
				</view>
			</view>
		</view>
</template>

<script>
	export default {
    name:'home',
		data() {
			return {
				isLogin: true,
				noLoginImgs: [{
					image: '/static/img/home/nologin.png',
					title: '昨夜星辰昨夜风，画楼西畔桂堂东'
				}, {
					image: '/static/img/home/nologin.png',
					title: '昨夜星辰昨夜风，画楼西畔桂堂东'
				}],
				permissList: null,
			};
		},
		created() {
			this.isLogin = uni.getStorageSync("isLogin")
      this.getMenus()
		},
		methods: {
			goMenusInfo(item) {
				this.navTo("/pages/comChilds/comChilds", this.isEmpty(item.children) ? '' : item.children,item.menuName)
			},
      getMenus(){
        let userAc = uni.getStorageSync("userAc")
        if (this.isLogin&&userAc.wxBind) {
          let userInfo=userAc.userInfo
          let roleIds = []
          if (userInfo.roles.length > 0) {
            userInfo.roles.forEach(item => {
              roleIds.push(item.roleId)
            })
          } else {
            roleIds.push(userInfo.roles[0].roleId)
          }
          roleIds=roleIds.toString()
          this.apis.commonApi.wxMiniMenuListVo({
            roleIds,
          }).then(res => {
            let resData = res.data
            if (resData.length > 0) {
              const data = this.toTree(resData)
              this.$store.commit("jurisdiction/setPrivilegesInfo", data[0].children)
              this.permissList =data[0].children
              console.log("permissList",this.permissList)
              // uni.setStorage({
              // 	key: "menuRolesTree",
              // 	data: data[0].children,
              // 	fail(err) {},
              // 	success(res) {}
              // })
              // uni.setStorageSync("menuRolesList", res.data)
            }


          }).catch(() => {

          })
        }
      }
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		position: relative;
		padding-bottom: 136rpx;
	}

	.top-wrap {
		width: 100%;
		height: 260rpx;
	}

	// 管理工具 s
	.glgj {
		margin-top: 20rpx;
		margin-bottom: 20rpx;
		padding: 0;
		width: 100%;

		.glgj-t {
			position: relative;
			width: 100%;
			height: 80rpx;
			padding-left: 40rpx;
			font-size: 26rpx;
			font-weight: 500;
			color: #888888;
			line-height: 36rpx;
			display: flex;
			align-items: center;

			&::after {
				position: absolute;
				content: "";
				width: 100%;
				height: 2rpx;
				bottom: 0;
				left: 0;
				background: #F6F6F6;
			}
		}

		.glgj-c {
			display: grid;
			width: 100%;
			grid-template-columns: repeat(3, 1fr);

			.glgj-col {
				width: 100%;
				height: 236rpx;
				overflow: hidden;
				display: flex;
				justify-content: center;
				flex-direction: column;
				align-items: center;
				border-right: 1rpx solid #f6f6f6;
				border-bottom: 1rpx solid #f6f6f6;

				image {
					margin-bottom: 22rpx;
					width: 70rpx;
					height: 70rpx;
				}

				&:nth-child(3n) {
					border-right: none;
				}

				view:nth-child(2) {
					font-size: 14px;
					font-weight: 500;
					color: #222222;
				}
			}
		}
	}

	// 管理工具 e






</style>
